Component without recurrence properties should enumerate just itself.
Reported by Rick DeNatale | May 19th, 2009 @ 12:47 PM | in 0.0.8
---------- Forwarded message ---------- From: Bruno
Duyé
Date: Tue, May 19, 2009 at 9:57 AM
Subject: RI_CAL question
To: rick.denatale@gmail.com
Hi Rick,
I found your adress in your GitHub profile.
I'm working on ics calendars on a Rails project. My goal is to get
a
list of legal holidays. I have a ics calendar that containts
that
list.
I first tried Icalendar (http://icalendar.rubyforge.org/)
but, as you
probably know, it appears that it's just a ICS fileformat parser
and
isn't able to generate a list of occurences.
So I turned myself to ri_cal.
I know how to parse a file to create a
RiCal::Component::Calendar
object (RiCal.parse(my_file)) but I can't find how to get an
Event
object to be able to call the
RiCal::OccurrenceEnumerator#occurrences
function who - if I understand well - is able to generate a list
of
dates for an event of a calendar.
I tried :
cal=RiCal.parse(my_cal_file)
then
irb(main):007:0> cal.first.events.first.occurrences
NoMethodError: undefined method bounded?' for<br/>
RiCal::OccurrenceEnumerator::EmptyRulesEnumerator:Class<br/>
from
/home/bruno/tmp/rubyredrick-ri_cal/lib/ri_cal/occurrence_enumerator.rb:113:in<br/>
bounded?'
from
/home/bruno/tmp/rubyredrick-ri_cal/lib/ri_cal/occurrence_enumerator.rb:117:in
to_a' from
/home/bruno/tmp/rubyredrick-ri_cal/lib/ri_cal/occurrence_enumerator.rb:137:in<br/>
occurrences'
from (irb):7
from :0
I suppose that it's not the regular way to do that.
Can you find the time to help me ?
I'm ok then to write a piece of doc explaining the best I can
howto
accumplish that.
Thanks for ri_cal !
Bruno Duyé
-- Bruno Duyé
Silicon Salad
9 place de St André
59000 Lile
http://www.siliconsalad.com/
Tel 03 69 61 60 70
Mob 06 89 55 38 41
Fax 03 69 61 60 71
Ligne directe 03 69 61 60 76
-- Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
Comments and changes to this ticket
-
Rick DeNatale May 19th, 2009 @ 12:53 PM
- Title changed from Fwd: RI_CAL question to EmptyRulesEnumerator bounded? missing?
-
Rick DeNatale May 19th, 2009 @ 12:54 PM
- Assigned user set to Rick DeNatale
-
Rick DeNatale May 19th, 2009 @ 02:35 PM
This bug might be a little misleading. The calendar file of French holidays actually has no recurring events. Instead there are multiple individual events for
Easter Monday 2007 Ascension day 2008 New Years day 2007 Fête du Travail (May Day) 2007 Armistice Day (WWII) 2007 Ascension day 2007 Easter Monday 2007 repeated in the file Bastille Day 2007 Feast of the Assumption 2007 etc.
The bug was that the occurrence enumerator was not propertly handing enumerating an event without recurrence rules, or recurrence lists I have changed it so that an component without properties generating recurrences will produce ONE occurrents, i.e. the component itself.
-
Rick DeNatale May 19th, 2009 @ 02:36 PM
- Title changed from EmptyRulesEnumerator bounded? missing? to Component without recurrence properties should enumerate just itself.
-
Rick DeNatale May 19th, 2009 @ 04:29 PM
- State changed from new to resolved
- Milestone set to 0.0.8
-
brunetton May 20th, 2009 @ 06:06 AM
Thanks Rick, the bug is resolved in 0.0.8.
But I still have a problem.
In french calendar, there are some events that repeats, and some that doesn't. For example, the event "Jour de l'an" is daily repeated :BEGIN:VEVENT
CREATED:20070605T163903Z
LAST-MODIFIED:20070606T161656Z
DTSTAMP:20070607T120859Z
UID:c6a930d6-4ed5-45d8-bb3d-d3587a32b8aa
SUMMARY:Jour de l'an
CLASS:PUBLIC
RRULE:FREQ=YEARLY;INTERVAL=1
DTSTART;VALUE=DATE;TZID=/mozilla.org/20070129_1/Europe/Paris:20070101
DTEND;VALUE=DATE;TZID=/mozilla.org/20070129_1/Europe/Paris:20070102
CATEGORIES:Jours fériés
END:VEVENTbut "Lundi de Pâques" for 2011 isn't :
BEGIN:VEVENT
CREATED:20070607T112742Z
LAST-MODIFIED:20070607T115439Z
DTSTAMP:20070607T120859Z
UID:570d9fe7-cdc9-4fdf-9794-909edf520383
SUMMARY:Lundi de Pâques
DTSTART;VALUE=DATE;TZID=/mozilla.org/20070129_1/Europe/Paris:20110425
DTEND;VALUE=DATE;TZID=/mozilla.org/20070129_1/Europe/Paris:20110426
CATEGORIES:Jours fériés
END:VEVENTI still don't understand how to get all occurrences for one of that events.
To be more precise, I've created a little ics file who only contains 2 events :
- "event1" on the 2009 June 1, never repeated - "event2" on the 2009 June 3, monthly repeatedThat file is attached
I suppose that there's a way to obtain an array of cal's events occurrences's dates, but I can't find how.
I mean I'm looking for a way to do :> cal = RiCal.parse('test.ics') > occurences1 = cal.first.events.first.occurences(:after => Date.parse('01/01/1990'), :before => Date.parse(01/01/2010))
and get an array that can be parsed with collect{} to obtain an array of Dates :
> occurences1.collect{|o| o[:begin_date]} => [#<Date: 01/06/2009>]
> occurences2 = cal.first.events[1].occurences(:after => Date.parse('01/01/1990'), :before => Date.parse(01/01/2010)) > occurences2.collect{|o| o[:begin_date]} => [#<Date: 03/06/2009>, #<Date: 03/07/2009>, #<Date: 03/08/2009>, #<Date: 03/09/2009>, #<Date: 03/10/2009>, #<Date: 03/11/2009>, #<Date: 03/12/2009>]
Maybe I am wrong and there's no way to do that ?
-
Rick DeNatale May 21st, 2009 @ 05:20 PM
Bruno,
I tried to verify your problem, but I'm not sure I understand.
It seems to work except that the second event occurences are getting DateTimes for their dtstart values instead of Dates.
Now I notice that you are thinking that occurrences returns a collection of hashes, it doesn't it returns a collection of components, e.g. Events so you should be using
o.dtstart
instead of
o[:begin_date]
-
brunetton May 25th, 2009 @ 09:25 AM
Hi Rick
Thanks for your response. The heart of my problem was that I didn't knew the Event::dtstart() function. Now I'm able to do :> cal.first.events[1].occurrences(:starting => Date.parse('2009-07-21'), :before => Date.parse('2009-10-21')).collect{|a| a.dtstart.to_s} => ["2009-08-03T00:00:00+00:00", "2009-09-03T00:00:00+00:00", "2009-10-03T00:00:00+00:00"]
It's perfect for me.
I can write then a piece of doc to help other people like me who are looking for a way to enumerate all occurences of an event.Thanks
-
Rick DeNatale May 25th, 2009 @ 09:26 AM
Perhaps you might consider adding something to the wiki on github under FAQs
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
A new icalendar data (RFC 2445) gem for Ruby which supports time zones and enumeration of occurrences
People watching this ticket
Attachments
Referenced by
- 6 Occurence enumeration should preserve type of datetimes This came out of a question from Bruno in response to Tic...